﻿using System;
using System.Collections.Generic;
using System.Linq;
using Gp.Scripts.Data;
using Gp.Scripts.Database;

using UnityEngine;

namespace Gp.Scripts.Core {
    [AutoLoad]
    public class BattleSystemConfig : SystemSystemConfig {
        protected override void OnLoad() {
            // var ruleConfig = LevelObjectConfigDatabase.Instance.basicConfig;
            // var defaultWeapon = LevelObjectConfigDatabase.Instance.defaultWeapon;

            // MoveActionConfigConfig moveConfig = null;
            // WeaponAttackConfigConfig attackConfig = null;
            
            // Dictionary<Type, BaseEntityConfigObject> dic = new();
            // foreach (var dataObject in SystemDataBase.Instance.dataObjects) {
            //     dic[dataObject.GetType()] = dataObject;
            //     
            //     // switch (dataObject) {
            //     //     case MoveActionConfigConfig move:
            //     //         moveConfig = move;
            //     //         break;
            //     //     case WeaponAttackConfigConfig attack:
            //     //         attackConfig = attack;
            //     //         break;
            //     // }
            // }
            //

            // this.RulesModel = new RulesModel(dic) {
            //     BasicRuleConfig          = ruleConfig,
            //     MoveActionEntityConfigEntityConfig   = null,
            //     WeaponAttackEntityConfigEntityConfig = null,
            //     DefaultWeapon            = defaultWeapon
            // };
            //
            // foreach (var type in GetType().Assembly.GetTargetType(baseClass: typeof(IGameAction), attribute:typeof(ActionRuleAttribute))) {
            //     var obj = Activator.CreateInstance(type) as IGameAction;
            //     RulesModel.BindAction(obj);
            //     Debug.Log($"已注册行为：{type}");
            // }
            RulesModel = new RulesModel(new Dictionary<Type, BaseEntityConfigObject>());
        }

        public UnitPrefabEntityConfig GetPlayerData()
        {
            return SystemDataBase.Instance.allCharacters.FirstOrDefault();
        }
        
        public RulesModel RulesModel { get; private set; }
    }
}